(in-package :moneychanger)

(defun convert-callback (&rest args)
  (declare (ignore args)))

(define-application-frame moneychanger (standard-application-frame)
    ((currencies :accessor currencies :initform (get-currencies)))
  (:panes 
	  (main-pane :application
		     :display-function 'display-main-pane
		     :scroll-bars nil)
	  (interactor :interactor)
	  (doc :pointer-documentation))
  (:layouts (default
 	       (vertically ()
		(200 main-pane))
		(200 interactor)
		doc)))

(defmethod display-main-pane ((frame moneychanger) stream)
  (princ "This space intentionally left blank" stream))

;(convert-button :push-button :label "Convert"
;                :callback 'convert-callback)
;(from-value :text-field
;            :editable-p t)
;(from-currency :option-pane
;               :items (get-currencies)
;               :name-key #'name
;               :value-key #'rate)
;(to-value :text-field
;          :editable-p nil)
;(to-currency :option-pane
;             :items (get-currencies)
;             :name-key #'name
;             :value-key #'rate)

(define-moneychanger-command (com-convert :name t)
    ((amount 'number :gesture :select :prompt "Amount"))
  (let ((stream (get-frame-pane *application-frame* 'interactor))
	(from-currency (menu-choose (mapcar #'name (get-currencies)))))
    (print amount stream)
    (print from-currency stream)))

(run-frame-top-level (make-application-frame 'moneychanger))